<?php
class Cos_Toolbox_Class
{
    const ID = '$Id: Class.php 40 2009-04-02 14:56:47Z vipzhicheng $';

    protected $_value = array();

    protected static $_method = array();

    public function __construct() {}

    public final static function addMethod($methodName, $funcRoute)
    {
        $function = Cos_Toolbox_Function::create($funcRoute);
        self::$_method[$methodName] = $function;
    }

    public final static function getMethods()
    {
        return array_keys(self::$_method);
    }

    protected function __call($method, $args)
    {
        if (isset(self::$_method[$method])) {
            $function = self::$_method[$method];
            array_push($args, $this);
            return call_user_func_array($function, $args);
        }
    }

    protected function __get($key)
    {
        return $this->_value[$key];
    }

    protected function __set($key, $value)
    {
        $this->_value[$key] = $value;
    }
}
